<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>isLocalStorageEnabled</title>
</head>
<body>
    <p>
        当前环境是否支持本地存储:
        <span id="storageText"></span>
    </p>
    <script>
        const isLocalStorageEnabled = () => {
            try {
                const key = `__storage__test`;
                window.localStorage.setItem(key,null);
                window.localStorage.removeItem(key);
                return true;
            } catch (e) {
                return false;
            }
        }
        document.getElementById('storageText').textContent = isLocalStorageEnabled()
    </script>
</body>
</html>